/**
 ********************************************************************
 * @author roocket
 * @file    sound_wav_pcm.h
 * @version V0.0.0
 * @date    2024/4/27
 * @brief   This file is to indicate wav pcm functions. 
 * @attention Code file rules:
 * rule: file encoding use UTF8;
 * rule: max line length 120 characters;
 * rule: line separator \r\n;
 * rule: use clion auto code format tool.
 */

#ifndef _SOUND_WAV_PCM_H_
#define _SOUND_WAV_PCM_H_
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>

/* definitions for wav format */
struct sound_wav_format
{
    unsigned char chunk_id[4];
    unsigned char chunk_size[4];
    unsigned char format[4];
    unsigned char sub_chunk_id1[4];
    unsigned char sub_chunk_size1[4];
    unsigned char audio_format[2];
    unsigned char num_channels[2];
    unsigned char sample_rate[4];
    unsigned char byte_rate[4];
    unsigned char block_align[2];
    unsigned char bits_per_sample[2];
    unsigned char sub_chunk_id2[4];
    unsigned char sub_chunk_size2[4];
};

/* wav to pcm format */
int sound_wav_to_pcm_format_file(const char *wav_file, const char *pcm_file);

#endif /* _SOUND_WAV_PCM_H_ */